#ifndef LOGGER_H
#define LOGGER_H

namespace Cvekas {

#define LOG(msg) (Log::log((msg), __FILE__, __LINE__))

/// Interface for logging messages
class LogListener : public boost::noncopyable
{
public:
	/// Called when Log attaches instance of LogListner
	virtual void add() = 0;

	/// Called on deattaching of LogListener
	virtual void remove() = 0;

	/// Called to send log message
	virtual void sendMsg(const std::string& msg) = 0;
};

typedef boost::shared_ptr<LogListener> LogListenerPtr;

/// Manages LogListeners and provides a way to send information to them.
class Log
{
public:
	/// Initializes logging. Must be called before any other Cvekas function
	static void init();
	
	/// Removes all listeners, clears internal arrays. The last function your program should call before exiting
	static void release();

	/// Logs message, notifies all registered listeners
	static void log(const std::string& msg, const std::string& file, int line);

	/// Registers new LogListener, calls LogListener::add()
	static void addListener(LogListenerPtr listener);
	
	/// Removes registered LogListeners, calls LogListener::remove()
	static void removeListener(LogListenerPtr listener);

private:
	static std::vector<LogListenerPtr> listeners;
	static std::vector<LogListenerPtr>::iterator itr;
};

} // namespace

#endif